<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>基本用法</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="outcontrol.examples.html">« 范例</a></li>
      <li style="float: right;"><a href="outcontrol.examples.rewrite.html">输出重写用法 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="outcontrol.examples.html">范例</a></li>
    <li>基本用法</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="outcontrol.examples.basic" class="section">
  <h2 class="title">基本用法</h2>
  <p class="para">
   <div class="example" id="example-532">
    <p><strong>示例 #1 输出控制举例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />ob_start</span><span style="color: #007700">();<br />echo&nbsp;</span><span style="color: #DD0000">"Hello\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"cookiename"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"cookiedata"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">ob_end_flush</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   在上面的例子中，<span class="function"><a href="function.echo.html" class="function">echo</a></span> 函数的输出将一直被保存在输出缓冲区中直到调用
   <span class="function"><a href="function.ob-end-flush.html" class="function">ob_end_flush()</a></span>。同时对 <span class="function"><a href="function.setcookie.html" class="function">setcookie()</a></span>
   的调用也成功存储了 cookie，而不会引起错误。（数据已发送到浏览器后，消息头通常无法发送。）
  </p>
 </div></div></div></body></html>